package com.dingding.activity.facade;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.dingding.activity.core.activity.dao.ICouponCityCacheDao;
import com.dingding.common.core.beans.activity.CouponCity;
import com.dingding.facde.activity.service.ICouponFacade;

/**
 * 
 * @Description: 优惠券服务接口
 * @author CHEHUANBO
 * @date 2016年12月15日
 * @version V2.6.2
 * 
 */
public class CouponFacadeImpl implements ICouponFacade{

	private static final Logger log = Logger.getLogger(CouponFacadeImpl.class);

	@Resource(name = "couponCityDao")
	private ICouponCityCacheDao couponCityCacheDao;

	/**
	 * 
	 * @Description: 获取所有的优惠券使用城市
	 * @author CHEHUANBO
	 * @version V2.6.2
	 * 
	 */
	@Override
	public Map<String, Object> getAllCouponCity(Map<String, Object> params) {

		Map<String, Object> resMap = new HashMap<String, Object>();

		if (params != null) {

			Integer couponId = (Integer) params.get("couponId");

			if (couponId == 0) {
				resMap.put("resStatus", false);
				resMap.put("resMasg", "参数不合法！" + params.toString());
				log.error("调用获取所有的优惠券使用城市被拒绝！原因：参数不合法，存在空值!");
			}

			List<CouponCity> couponCityList = null;

			try {

				couponCityList = couponCityCacheDao.getCouponCityToCache(couponId);

				resMap.put("resStatus", true);
				resMap.put("resMsg", "");
				resMap.put("couponCityList", couponCityList);

			} catch (Exception e) {
				resMap.put("resStatus", false);
				resMap.put("resMasg", "服务器异常！");
			}

		} else {
			resMap.put("resStatus", false);
			resMap.put("resMasg", "参数不合法！");
		}

		return resMap;

	}

}
